use std::process::Command;

#[tokio::test]
async fn broadcast_block() {
    println!("cwd: {}", std::env::current_dir().unwrap().display());

    let status = Command::new("cargo")
        .args(["build"])
        .spawn()
        .expect("failed to execute process")
        .wait()
        .expect("waiting for process to finish");
    assert!(status.success());

    let mut rx_transaction_process = Command::new("../target/debug/broadcast_transaction_rx_node")
        .spawn()
        .expect("failed to execute process");

    tokio::time::sleep(std::time::Duration::from_secs(1)).await;

    let mut tx_transaction_process = Command::new("../target/debug/broadcast_transaction_tx_node")
        .spawn()
        .expect("failed to execute process");

    let tx_status = tx_transaction_process
        .wait()
        .expect("waiting for process to finish");
    let rx_status = rx_transaction_process
        .wait()
        .expect("waiting for process to finish");
    assert!(tx_status.success());
    assert!(rx_status.success());
}
